package leetcode.greed;

import java.util.Arrays;

/**
 * Created by zxc on 2018/10/4.
 */
public class AssignCookies {
    /**/
    private static int findContentChildren(int[] g, int[] s) {
        Arrays.sort(g);
        Arrays.sort(s);
        int child = 0;
        int cookie =0;
        while (child < g.length && cookie < s.length){
            if(g[child] <= s[cookie]){
                child++;
            }
            cookie++;
        }
        return child;
    }

    public static void main(String[] args) {
        // 孩子需求因素
        int[] g = {5,10,2,9,15,9};
        // 糖果大小
        int[] s = {6,1,20,3,8};

        /*排序*/
        int number = findContentChildren(g, s);

        System.out.println("满足孩子的个数：" + number);
    }
}
